package com.neu.credit.creditscore.common.mgb;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class PlusGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create(
                        "jdbc:mysql://rm-cn-yzh4c7xne000eq1o.rwlb.rds.aliyuncs.com/fico?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai",
                        "user", "QWER1234@")
                .globalConfig(builder -> {
                    builder
                            .disableOpenDir()
                            .enableSwagger() // 开启 swagger 模式
                            .outputDir("E:\\idea-workspace\\west-lake-credit\\CreditLife\\src\\main\\java") // 指定输出目录
                    ;
                })
                .packageConfig(builder -> {
                    builder.parent("com.neu.credit") // 设置父包名
                            .moduleName("creditscore") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\idea-workspace\\west-lake-credit\\CreditLife\\src\\main\\resources\\mapper")) // 设置mapperXml生成路径
                    ;
                })
                .strategyConfig(builder -> {
                    builder// 设置需要生成的表名

//                            .addInclude("departments")
  //                          .addInclude("credit_score")
                            .addInclude(" transmissionJson")
//                            .addInclude("appointments")
//                            .addInclude("examination_items")
//                            .addInclude("prescription_drugs")
//                            .addInclude("diagnosis_records")
//                            .addInclude("examination_orders")
//                            .addInclude("prescriptions")
//                            .addInclude("fees")
//                            .addInclude("topic")
//                            .addInclude("sys_role")
//                            .addInclude("sys_permission")
//                            .addInclude("book_listing")

//                            .addTablePrefix("volun_")
                            .entityBuilder()
                            .enableLombok() //使用lombok
                            .disableSerialVersionUID()
                            //.enableTableFieldAnnotation()
//                                    .addTableFills(Arrays.asList(
//                                            new Column("create_time", FieldFill.INSERT),
//                                            new Column("create_user", FieldFill.INSERT),
//                                            new Column("update_time", FieldFill.INSERT_UPDATE),
//                                            new Column("update_user", FieldFill.INSERT_UPDATE)
//                                    ))
//                                .logicDeleteColumnName("is_deleted")
//                            .fileOverride()
                            .controllerBuilder()
                            .enableRestStyle()
                            //.fileOverride()
                            .mapperBuilder()
                            .enableMapperAnnotation()
                            .enableBaseResultMap()
                            //.enableBaseColumnList()
                            .fileOverride()
                            .serviceBuilder()
                            .formatServiceFileName("%sService")
                            .formatServiceImplFileName("%sServiceImpl")
                    //.fileOverride()
                    ;
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }

}